//
//  SSSBaseViewController.m
//  SSSMerchant
//
//  Created by 谢曦 on 2017/3/22.
//  Copyright © 2017年 xnxin. All rights reserved.
//

#import "SSSBaseTableViewController.h"

@interface SSSBaseTableViewController ()

@end

@implementation SSSBaseTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor=[UIColor colorWithHex:@"F6F6F6"];
     [self tableView];
     [self bottomBar];
     self.isShowBottomBar=NO;
    
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.hidesBottomBarWhenPushed=YES;
}
-(void)viewDidDisappear:(BOOL)animated{
    [super viewDidDisappear:animated];
     self.hidesBottomBarWhenPushed=NO;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _dataArr.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return [UITableViewCell new];
}
-(void)setBottomBarTitle:(NSString *)bottomBarTitle{
    _bottomBarTitle=bottomBarTitle;
    UILabel *lable=[self.bottomBar viewWithTag:100];
    lable.text=bottomBarTitle;
}
-(void)setBottomBarAttribute:(NSAttributedString *)bottomBarAttribute{
    _bottomBarAttribute=bottomBarAttribute;
    UILabel *lable=[self.bottomBar viewWithTag:100];
    lable.attributedText=bottomBarAttribute;
}

-(void)setIsShowBottomBar:(BOOL)isShowBottomBar{
    _isShowBottomBar=isShowBottomBar;
    self.bottomBar.hidden=!isShowBottomBar;
    if (self.bottomBar.hidden==NO) {
        self.tableView.height-=self.bottomBar.height;
    }
}
-(UIView *)bottomBar{
    if (!_bottomBar) {
       _bottomBar=[[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 54)];
        _bottomBar.backgroundColor=ThemeGreenColor;
        [self.view addSubview:_bottomBar ];
        
        UILabel *attrLabel = [UILabel new] ;
        attrLabel.tag=100;
        [attrLabel sizeToFit];
        [_bottomBar addSubview:attrLabel];
        attrLabel.textColor=[UIColor whiteColor];
        [_bottomBar mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.view);
            make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 40));
        }];
        
        
        [attrLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(_bottomBar);
            
        }];

    }
    return _bottomBar;
}
-(UITableView *)tableView
{
    if (!_tableView) {
        _tableView=[[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) style:UITableViewStylePlain];
        _tableView.backgroundColor=[UIColor colorWithHex:@"F6F6F6"];
        _tableView.delegate=self;
        _tableView.dataSource=self;
        _tableView.tableFooterView=[UIView new];
        _tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
        [self.view addSubview:_tableView];
    }
    
    return _tableView;
    
}
@end
